home *** CD-ROM | disk | FTP | other *** search
- package asp.wizard;
-
- import asp.util.ResourceUtil;
- import asp.wizard.util.UiUtil;
- import com.sun.java.swing.ComboBoxEditor;
- import com.sun.java.swing.DefaultCellEditor;
- import com.sun.java.swing.JButton;
- import com.sun.java.swing.JComboBox;
- import com.sun.java.swing.JPanel;
- import com.sun.java.swing.JScrollPane;
- import com.sun.java.swing.JTable;
- import com.sun.java.swing.table.DefaultTableModel;
- import com.sun.java.swing.table.TableColumnModel;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.GridBagConstraints;
- import java.awt.GridBagLayout;
- import java.util.EventObject;
- import java.util.Vector;
-
- public class WVPanelDbQueryWhere extends WVPanelBase {
- private static final String ID_BTN_ADD = "button.add";
- private static final String ID_BTN_DELETE = "button.delete";
- private static final String ID_LBL_HDRFIELD = "label.headerfield";
- private static final String ID_LBL_HDRFILTER = "label.headerfilter";
- private static final String ID_LBL_HDRVALUE = "label.headervalue";
- private static final int INIT_ROWS = 0;
- JButton _btnAdd;
- JButton _btnDelete;
- JComboBox _cboCritPrefix;
- JComboBox _cboLhs;
- JComboBox _cboOperator;
- JComboBox _cboRhs;
- JComboBox _cboCritSuffix;
- JTable _tblCriteria;
- DefaultTableModel _tbmCriteria;
- JScrollPane _scpCriteria;
-
- protected void initModels() {
- super.initModels();
- ResourceUtil ru = ((WVPanelBase)this).getResourceUtil();
- Vector tableColumns = new Vector();
- tableColumns.addElement(" ");
- tableColumns.addElement(ru.getString("label.headerfield"));
- tableColumns.addElement(ru.getString("label.headerfilter"));
- tableColumns.addElement(ru.getString("label.headervalue"));
- tableColumns.addElement(" ");
- Vector tableData = new Vector(0);
- Vector tableRow = null;
-
- for(int i = 0; i < 0; ++i) {
- tableRow = new Vector();
- tableRow.setSize(5);
- tableData.addElement(tableRow);
- }
-
- this._tbmCriteria = new DefaultTableModel();
- this._tbmCriteria.setDataVector(tableData, tableColumns);
- }
-
- protected void initComponents() {
- super.initComponents();
- ResourceUtil ru = ((WVPanelBase)this).getResourceUtil();
- JPanel contentPanel = ((WVPanelBase)this).getContentPanel();
- Color bgcolor = ((Component)contentPanel).getBackground();
- this._btnAdd = new JButton(ru.getString("button.add").trim());
- this._btnAdd.setMnemonic(ru.getMnemonic("button.add"));
- this._btnDelete = new JButton(ru.getString("button.delete"));
- this._btnDelete.setMnemonic(ru.getMnemonic("button.delete"));
- this._cboCritPrefix = new JComboBox();
- this._cboCritPrefix.setEditable(false);
- this._cboLhs = new JComboBox();
- this._cboLhs.setEditable(false);
- this._cboOperator = new JComboBox();
- this._cboOperator.setEditable(false);
- this._cboRhs = new JComboBox();
- this._cboRhs.setEditable(true);
- this._cboRhs.addItemListener(new 1());
- this._cboCritSuffix = new JComboBox();
- this._cboCritSuffix.setEditable(false);
- this._tblCriteria = new JTable();
- this._tblCriteria.setModel(this._tbmCriteria);
- TableColumnModel tcm = this._tblCriteria.getColumnModel();
- this._scpCriteria = JTable.createScrollPaneForTable(this._tblCriteria);
- DefaultCellEditor cde = new DefaultCellEditor(this._cboCritPrefix);
- cde.setClickCountToStart(2);
- tcm.getColumn(0).setCellEditor(cde);
- cde = new DefaultCellEditor(this._cboLhs);
- cde.setClickCountToStart(2);
- tcm.getColumn(1).setCellEditor(cde);
- cde = new DefaultCellEditor(this._cboOperator);
- cde.setClickCountToStart(2);
- tcm.getColumn(2).setCellEditor(cde);
- cde = new CustomComboBoxCellEditor(this, this._cboRhs);
- cde.setClickCountToStart(2);
- cde.addCellEditorListener(new 2());
- tcm.getColumn(3).setCellEditor(cde);
- cde = new DefaultCellEditor(this._cboCritSuffix);
- cde.setClickCountToStart(2);
- tcm.getColumn(4).setCellEditor(cde);
- int nWidth = 494;
- tcm.getColumn(0).setMaxWidth(nWidth / 9);
- tcm.getColumn(0).setWidth(nWidth / 9);
- tcm.getColumn(1).setMaxWidth(nWidth / 3);
- tcm.getColumn(1).setWidth(nWidth / 3);
- tcm.getColumn(2).setMaxWidth(nWidth / 9);
- tcm.getColumn(2).setWidth(nWidth / 9);
- tcm.getColumn(3).setMaxWidth(nWidth / 3);
- tcm.getColumn(3).setWidth(nWidth / 3);
- tcm.getColumn(4).setMaxWidth(nWidth / 9);
- tcm.getColumn(4).setWidth(nWidth / 9);
- this._tblCriteria.setAutoResizeMode(0);
- this._tblCriteria.getTableHeader().setReorderingAllowed(false);
- this._tblCriteria.getTableHeader().setResizingAllowed(false);
- }
-
- protected void initLayout() {
- super.initLayout();
- JPanel contentPanel = ((WVPanelBase)this).getContentPanel();
- GridBagLayout gbl = new GridBagLayout();
- GridBagConstraints gbc = new GridBagConstraints();
- ((Container)contentPanel).setLayout(gbl);
- gbc.ipady = 5;
- UiUtil.addComponent(contentPanel, super._txpIntro, gbl, gbc, 0, 0, 3, 1, (double)1.0F, (double)0.0F, 10, 2, 0, 0, 10, 0);
- gbc.ipady = 0;
- UiUtil.addComponent(contentPanel, this._scpCriteria, gbl, gbc, 0, 1, 3, 1, (double)1.0F, (double)1.0F, 10, 1, 5, 5, 0, 5);
- TableColumnModel tcm = this._tblCriteria.getColumnModel();
- UiUtil.addComponent(contentPanel, new JPanel(), gbl, gbc, 0, 2, 1, 1, (double)1.0F, (double)0.0F, 13, 0, 10, 0, 0, 0);
- UiUtil.addComponent(contentPanel, this._btnAdd, gbl, gbc, 1, 2, 1, 1, (double)0.0F, (double)0.0F, 13, 0, 10, 0, 0, 0);
- UiUtil.addComponent(contentPanel, this._btnDelete, gbl, gbc, 2, 2, 1, 1, (double)0.0F, (double)0.0F, 13, 0, 10, 0, 0, 0);
- }
-
- public void commitValue(EventObject evt) {
- if (evt.getSource() instanceof DefaultCellEditor) {
- DefaultCellEditor dce = (DefaultCellEditor)evt.getSource();
- if (dce.getComponent() instanceof JComboBox) {
- JComboBox comboBox = (JComboBox)dce.getComponent();
- if (comboBox.isEditable()) {
- ComboBoxEditor cbe = comboBox.getEditor();
- if (cbe != null) {
- Object item = cbe.getItem();
- int editingRow = this._tblCriteria.getEditingRow();
- int editingColumn = this._tblCriteria.getEditingColumn();
- if (editingRow >= 0 && editingColumn >= 0) {
- this._tblCriteria.setValueAt(item, editingRow, editingColumn);
- }
- }
- }
- }
- }
-
- }
-
- public void commitValues(EventObject evt) {
- System.out.println("handleComboBoxFocusLost");
- }
- }
-